package main.java.chessfootball.gameplay;

import main.java.chessfootball.model.exception.RuleViolationException;
import main.java.chessfootball.model.game.Game;
import main.java.chessfootball.model.play.Move;
import main.java.chessfootball.model.play.Put;
import main.java.chessfootball.model.play.Turn;
import main.java.chessfootball.rules.RuleChecker;
import main.java.chessfootball.model.rule.Rule;

/**
 * User: Igor
 * Date: 11.06.2011
 * Time: 10:10:48
 */
public class GamePlay
{
	private Game game;
	private History history;
	private RuleChecker rule = new RuleChecker();

	public GamePlay(Rule rule)
	{
		game = new Game(rule);
	}

	public void move(Move to) throws RuleViolationException
	{
		rule.checkMove(game, to);
		game.move(to);
	}

	public void cancelMove()
	{
		//todo
	}

	public void put(Put on) throws RuleViolationException
	{
		rule.checkPut(game, on);
		game.put(on);
	}

	public void turn(Turn turn)
	{
		rule.checkTurn(game, turn);
	 	game.turn(turn);
	}

	public void turn() throws RuleViolationException
	{
		rule.checkTurn(game);
	 	game.turn();
	}

	public Game getGame()
	{
		return game;
	}

	public History getHistory()
	{
		return history;
	}
}
